package com.findmeastore.action;

import java.util.Map;

import com.findmeastore.bc.IUserBc;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;


public class LoginAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private String username;
	private String password;
	private IUserBc userBc;
	
	public String execute() {
		Map session = ActionContext.getContext().getSession();
		if(userBc.isValidUser(username, password)){
			session.put("logged-in", true);
			session.put("user",username);
			return "SUCCESS";
		} else {
			return "ERROR";
		}
		
	}
	
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public IUserBc getUserBc() {
		return userBc;
	}

	public void setUserBc(IUserBc userBc) {
		this.userBc = userBc;
	}
}
